describe("ArrayUtil", function() {
    var array;
    describe("groupBy", function() {
        beforeEach(function() {
            array = [{
                name: "demo1",
                age: 13
            }, {
                name: "demo2",
                age: 14
            }, {
                name: "demo4",
                age: 13
            }]

        })
        it("can group the different Value", function() {
            var result = jc.Array.groupBy(array, "age")
            expect(getType(result)).toEqual("object")
            expect(Object.keys(result)).toEqual(["13", "14"])
            expect(result[13].length).toEqual(2)
            expect(result[14].length).toEqual(1)

        })

        it("filter can work", function() {
            var result = jc.Array.groupBy(array, "age", function(elem) {
                return elem.age == 13
            })
            expect(result[14]).toBeUndefined()
        })
    })
    describe('objToArr', function() {
        var obj;
        beforeEach(function() {
            obj = {
                k1: "v1",
                k2: "v2"
            }
        })
        it("can work", function() {
            expect(jc.Array.objToArr(obj)).toEqual([{
                key: "k1",
                value: "v1"
            }, {
                key: "k2",
                value: "v2"
            }])
        })
    });

    describe('getDistinct', function() {
        it('can work', function() {
            var testArr = [1, 4, 1, 5, 3, 5, 7]
            expect(jc.Array.getDistinct(testArr)).toEqual([1, 4, 5, 3, 7])
        })
    })


})